<?php

require_once __DIR__ . '/core.php';

// 获取语言
$lang = $con->request->get('lang');
$id = $con->db->table('role')->find('id')->where('r_url = ?', ['content.php?lang='.$lang])->one();
if (!$id) {
    die('指定语言不存在');
}
// 拼接标签
$roles = $con->db->table('role')->find('id, pid, r_url, r_name')->where('r_on = ? AND pid = ?', [1, $id['id']])->all();
$tags = '';
$path = $hel->path();
$i = 1;
if (in_array('1', $user_role) || in_array('3', $user_role) || in_array($id['id'], $user_role)) {
    foreach ($roles as $role) {
        $tags .= '<li><a href="'.$path.'/'.$role['r_url'].'"><img src="'.$path.'/img/c'.$i.'.png">  '.$role['r_name'].'</a></li>';
        $i++;
    }
} else {
    foreach ($roles as $role) {
        if (in_array($role['id'], $user_role)) {
            $tags .= '<li><a href="' . $path . '/' . $role['r_url'] . '"><img src="' . $path . '/img/c' . $i . '.png">  ' . $role['r_name'] . '</a></li>';
        }
        $i++;
    }
}
$con->render('content', [
    'path' => $path,
    'lang' => $con->request->get('lang'),
    'tags' => $tags,
]);